import os
from http import HTTPStatus
from tkinter import W
# dashscope sdk >= 1.23.4
from dashscope import VideoSynthesis
from .generate_qrcode import get_qrcode
import base64
from config import Config
# 从环境变量中获取 DashScope API Key（即阿里云百炼平台 API key）
api_key ="sk-ebb89e4f8e5948a5940af92854230df5"



def get_video(img_url, prompt):
    SAVE_PATH = Config.PATH_IMAGE_VIDEO
    # call sync api, will return the result
    print('please wait...')
    rsp = VideoSynthesis.call(api_key=api_key,
                              model='wanx2.1-i2v-turbo',
                              prompt=prompt,
                              img_url=img_url)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
        return rsp.output.video_url
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))


    





